package com.bangf.repo;

import com.bangf.domain.FpVillage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface VillageRepo extends JpaRepository<FpVillage,Integer> {


    @Query(value =  "SELECT * FROM fp_village " +
                    "WHERE town_id = ?1",nativeQuery = true)
    List<FpVillage> findAllByTownId(Integer townId);


    @Query(value =  "SELECT count(*) FROM fp_village " +
                    "WHERE is_poor = 1 " +
                    "AND town_id = ?1",nativeQuery = true)
    Integer countPoorVillage(Integer townId);
}
